<template lang="pug">
	.record-list-wrap
		.record-noItem-box(v-if="noItem")
			no-item(text="当前无就诊记录")
		.record-item(v-for="(item,index) in list" :key="index" @click="jumpToDetail(item)")
			.item-header
				.object-name 项目名称（{{item.item_name}}）
				.state {{item.statusText}}
			.item-content
				div
					.left 开单医生
					.right {{item.doc_name}}
				div
					.left 总费用
					.right ￥{{item.zje}}
				div
					.left 医保报销
					.right -￥{{item.ybje}}
			.item-footer
				.fee
					.left 自费金额
					.right ￥{{item.zfje1}}
				.hint(v-if="item.prompt_msg") {{item.prompt_msg}}
</template>

<script>
import noItem from '@/components/no-item'
export default {
	name: 'doctorRecordList',
	data() {
		return {
			list: [],
			noItem: false
		}
	},
	created() {},
	mounted() {
		this.doctorRecordList()
	},
	methods: {
		jumpToDetail(item) {
			this.wx.setStorage({
				key: 'doctorRecordList',
				data: item
			})
			this.$router.push({
				path: '/views/doctorRecord/doctorRecordDetail'
			})
		},
		doctorRecordList() {
			this.wx.showLoading({
				title: '加载中',
				icon: 'none'
			})
			let findPatient = this.wx.getStorageSync('findPatient')
			let userInfo = this.wx.getStorageSync('userInfo')
			this.api.jtApi
				.doctorRecordList({
					access_token: userInfo.accessToken,
					member_num: userInfo.memberNum,
					klx: findPatient.cardType,
					kh: findPatient.cardNumber,
					sjh: findPatient.phone,
					brxm: findPatient.name,
					sfzhm: findPatient.idNumber,
					org_code: this.wx.getStorageSync('findHospital').orgCode,
					status: '00',
					hosflowno_g: this.$route.query.hosflownog
				})
				.then(data => {
					this.wx.hideLoading()
					if (data.ret_code === '0') {
						let list = this.tools.formatToArray(data.details.detail)
						list.forEach(item => {
							if (
								item.status === '21' ||
								item.status === '01' ||
								item.status === '11' ||
								item.status === '41' ||
								item.status === '40' ||
								item.status === '42'
							) {
								item.statusText = '未支付'
							} else {
								item.statusText = '已支付'
							}
							item.zje = this.filter.formatIncome(item.zje)
							item.ybje = this.filter.formatIncome(item.ybje)
							item.zfje1 = this.filter.formatIncome(item.zfje1)
						})
						this.list = list
					}
					this.noItem = this.list.length <= 0
				})
				.catch(() => {
					this.noItem = this.list.length <= 0
					this.wx.hideLoading()
				})
		}
	},
	components: {
		noItem
	}
}
</script>

<style lang="stylus">
	.record-list-wrap
		padding-top 20px
		position relative
		.record-item
			margin-bottom 20px
			padding 0 30px
			background-color white
			>div
				&:last-child
					border-bottom none
			.item-header
				padding 30px 0
				display flex
				justify-content space-between
				align-items center
				font-size 30px
				.object-name
					font-weight 600
					color blackFontColor1A
				.state
					text-align right
					min-width 25%
					color #FDAF3D
			.item-content
				padding-top 0
				border-bottom borderStyle
				>div
					display flex
					justify-content space-between
					align-items center
					font-size 28px
					margin-bottom 30px
					.left
						color grayFontColor88
					.right
						text-align right
						min-width 25%
						color blackFontColor1A
			.item-footer
				padding-bottom 30px
				.fee
					padding-top 30px
					display flex
					justify-content space-between
					font-size 28px
					.left
						color grayFontColor88
					.right
						text-align right
						min-width 25%
						color blackFontColor1A
				.hint
					margin-top 30px
					font-weight 400
					color themeColor
					text-align right
					font-size 30px
					line-height 34px
					span
						color #2693FF
						font-size 30px
						margin-left 15px
				.btn
					width 152px
					height 56px
					font-size 26px
					center()
					color white
					border-radius 36px
					background linear-gradient(90deg,rgba(76,142,255,1) 0%,rgba(54,162,255,1) 100%)
		.record-noItem-box
			position absolute
			z-index 2
			cover()
			center()
</style>
